<template>
	<view class="review-con">
		<web-view v-if="path.pdf" :update-title="false" :src="path.pdf"></web-view>
		<image v-if="path.img" :src="path.img" mode=""></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// PDF路径前缀
				pdfPrefix: "/static/pdfjs/web/viewer.html?file=",
				path: {
					pdf: "",
					img: ""
				},
			}
		},
		methods: {
			init(path) {
				if (path.endsWith('.pdf')) {
					this.path.pdf = this.pdfPrefix + path;
				} else {
					this.path.img = decodeURIComponent(path).replace(/\\/g,'/');
				}
			},
		},
		onLoad(e) {
			let jpg = "http://192.168.101.242:9000/ewaybill/upload/20221028/10c531fb74abcb35bdcc175c523db1f3.jpg";
			let pdf = "http://192.168.101.242:9000/billpdf/upload/20221028/b1e2482617da491845a3f29bac2690e5.pdf";
			if (!e.url) {
				this.$goBack(1, 1);
			} else {
				const url = e.url;
				this.init(url);
			}
		}
	}
</script>

<style lang="scss">
	.review-con {
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;

		image {
			max-width: 100%;
			max-height: 100%;
		}
	}
</style>
